<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<style>
    td input{
        width: 100%;
        line-height: 1.5;
        vertical-align: top;
        border-top: 2px solid #f7f7f7; /*边框颜色*/
        outline:none;
    }
</style>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-purchases-edit">
        <div class="form-group">
            <label class="col-sm-3 control-label">internationalExpressNumber：</label>
            <div class="col-sm-8">
                <input id="overseasExpressNo" name="overseasExpressNo" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label"><span class="must_be_color">*</span>internationalExpressID：</label>
            <div class="col-sm-8">
                <select class="form-control" id="overseasExpressCompanyID" name="overseasExpressCompanyID"
                        th:with="type=${@dict.getType('erp_overseas_courier')}">
                    <option th:each="dict : ${type}" th:text="${dict['dictLabel']}"
                            th:value="${dict['dictValue']}"></option>
                </select>
            </div>
        </div>
        <!--需要批量的id集合-->
        <input name="ids" type="hidden" th:value="${ids}">
        <!--发往海外仓标识-->
        <input id="chinaReceived" name="chinaReceived" value="1" class="form-control"
               type="hidden">
        <div class="form-group">
            <div class="form-control-static col-sm-offset-9">
                <button type="submit" class="btn btn-primary">submit</button>
                <button onclick="$.modal.close()" class="btn btn-danger" type="button">close</button>
            </div>
        </div>

    </form>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script type="text/javascript">
    var prefix = ctx + "module/purchases"
    $("#form-purchases-edit").validate({
        /*submitHandler: function (form) {
            //$.operate.save(prefix + "/add", $('#form-purchases-add').serialize());
        }*/
        rules: {
            overseasExpressNo: {
                required: true,
            }
        },
        messages: {
            "overseasExpressNo": {
                remote: "快递单号不能为空！"
            }
        },
        submitHandler: function (form) {
            edit();
        }
    });

    function edit() {
        var ids = $("input[name='ids']").val();
        var chinaReceived = $("input[name='chinaReceived']").val();
        var overseasExpressNo = $("input[name='overseasExpressNo']").val();
        var overseasExpressCompanyID = $("#overseasExpressCompanyID option:selected").val();

        $.ajax({
            cache : true,
            type : "POST",
            url : ctx + "module/purchases/edit_overseas_batch",
            data : {
                "ids" : ids,
                "chinaReceived":chinaReceived,
                "overseasExpressNo" : overseasExpressNo,
                "overseasExpressCompanyID" : overseasExpressCompanyID,
            },
            async : false,
            error : function(request) {
                $.modal.alertError("system error");
            },
            success : function(data) {
                $.operate.saveSuccess(data);
            }
        });
    }
</script>
</body>
</html>
